#if ( !defined __PROXY_HUNTER_HPP__ )
#define __PROXY_HUNTER_HPP__

#define HOST_TEST_PROXY "119.40.35.7"
#define PATH_TEST_PROXY "/"

#include <string>
#include <vector>

#include "webpage_hunter.hpp"
#include "proxy_reader.hpp"

using namespace std;

class ProxyHunter
{
public:
	ProxyHunter ( const string& db_file, const string& protocol, const string& host, const vector< string >& paths, const HttpHeaderPairs& headers, const vector < string >& expressions );
	~ProxyHunter ();
public:
	void operator()();
protected:
	bool read_webpage ( const string& protocol, const string& hostname, const string path, HttpHeaderPairs& headers, ostream& header_stream, ostream& content_stream );
	void read_try ( int count, const string& protocol, const string& hostname, const string path, HttpHeaderPairs& headers, ostream& header_stream, ostream& content_stream  );
	void parse_webpage ( stringstream& header_stream, stringstream& content_stream );
	void search_proxies ( const string& expr, const string& page_content, vector < string >& proxies );
private:
	string _protocol;
	string _hostname;
	HttpHeaderPairs _headers;
	
	vector < string > _expressions;
	vector < string > _paths;

	ProxyReader* _reader;
};

#endif // __PROXY_HUNTER_HPP__